/**
 * Class:Utilisateur		  
 * @author Masaoudi Anass - Najem Ali
 * @version 1.0 
 */

package com.mycompany.biblio.model;


import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

@Entity
@NamedQueries({
    @NamedQuery(name = Utilisateur.FIND_ALL, query = "SELECT u FROM Utilisateur u"),
    @NamedQuery(name = Utilisateur.FIND_BY_USERNAME, query = "SELECT u FROM Utilisateur u WHERE u.username = :username"),
})
public class Utilisateur implements Serializable {

    public final static String FIND_ALL = "Utilisateur.findAll";
    public final static String FIND_BY_USERNAME = "Utilisateur.findByUsername";
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name="utilisateur_id")

    private Long id;
    protected String nom;
    protected String prenom;
    protected String numtel;
    protected String adresse;
    protected String email;
    protected String ville;
    protected String region;
    protected String pays;
    protected String sexe;
  
    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "utilisateur_u")
    private List<Immobilier> immobiliers;
    
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "utilisateur_u")
    private List<Service> services;
    
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "utilisateur_u")
    private List<Vehicule> vehicules;
    
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "utilisateur_u")
    private List<Emploi> emplois;
    
    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name = "utilisateur_u")
    private List<Autre> autres;
    
    protected String username;
    protected String password;
    @Transient
    private boolean selected;

    // ======================================
    // =            Constructors            =
    // ======================================
    public Utilisateur() {
    }

    public Utilisateur(String nom, String prenom, String numtel, String adresse, String email, String ville, String region, String pays, String sexe, String username, String password, boolean isadmin, boolean selected) {
        this.nom = nom;
        this.prenom = prenom;
        this.numtel = numtel;
        this.adresse = adresse;
        this.email = email;
        this.ville = ville;
        this.region = region;
        this.pays = pays;
        this.sexe = sexe;
        this.username = username;
        this.password = password;
       // this.isadmin = isadmin;
        this.selected = selected;
    }

    // ======================================
    // =          Getters & Setters         =
    // ======================================
   
    public String getNom() {
        return nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public String getNumtel() {
        return numtel;
    }

    public String getAdresse() {
        return adresse;
    }

    public String getEmail() {
        return email;
    }

    public String getVille() {
        return ville;
    }

    public String getRegion() {
        return region;
    }

    public String getPays() {
        return pays;
    }

    public String getSexe() {
        return sexe;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    public Long getId() {
        return id;
    }

    public List<Immobilier> getImmobiliers() {
        return immobiliers;
    }

    public List<Service> getServices() {
        return services;
    }

    public List<Vehicule> getVehicules() {
        return vehicules;
    }

    public List<Emploi> getEmplois() {
        return emplois;
    }

    public List<Autre> getAutres() {
        return autres;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public void setNumtel(String numtel) {
        this.numtel = numtel;
    }

    public void setAdresse(String adresse) {
        this.adresse = adresse;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setVille(String ville) {
        this.ville = ville;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public void setPays(String pays) {
        this.pays = pays;
    }

    public void setSexe(String sexe) {
        this.sexe = sexe;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

   /* public void setIsadmin(boolean isadmin) {
        this.isadmin = isadmin;
    }*/

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public void setImmobiliers(List<Immobilier> immobiliers) {
        this.immobiliers = immobiliers;
    }

    public void setServices(List<Service> services) {
        this.services = services;
    }

    public void setVehicules(List<Vehicule> vehicules) {
        this.vehicules = vehicules;
    }

    public void setEmplois(List<Emploi> emplois) {
        this.emplois = emplois;
    }

    public void setAutres(List<Autre> autres) {
        this.autres = autres;
    }
    
    
    

    // ======================================
    // =         hash, equals, toString     =
    // ======================================
    @Override
  public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("Utlisateur");
        sb.append("{id=").append(id);
        sb.append(", nom='").append(nom).append('\'');
        sb.append(", prenom=").append(prenom);
        sb.append(", numtel='").append(numtel).append('\'');
        sb.append(", adresse='").append(adresse).append('\'');
        sb.append(", email=").append(email).append('\'');
        sb.append(", ville='").append(ville).append('\'');
        sb.append(", region='").append(region).append('\'');
        sb.append(", pays=").append(pays).append('\'');
        sb.append(", sexe='").append(sexe).append('\'');
        sb.append(", username='").append(username).append('\'');
        sb.append(", password=").append(password).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
